package cn.edu.sju;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class work06
{
    
    public static void main(String[] args) throws ClassNotFoundException
    {
    
        ObjectInputStream ois=null;
        try {
            ois=new ObjectInputStream(new FileInputStream("C:\\myDoc\\stu.txt"));
            Student stu=(Student)ois.readObject();
            System.out.println("姓名为："+stu.getName());
            System.out.println("年龄为："+stu.getAge());
            System.out.println("性别为："+stu.getGender());
        }catch(IOException ex) {
            ex.printStackTrace();
        }finally {
            if(ois!=null) {
                try {
                    ois.close();
                }catch(IOException e) {
                    e.printStackTrace();
                }
            }

}
}
}